﻿using System;
using System.Globalization;
using System.Text.RegularExpressions;

class ExtractDatesFromText
{
    static void Main()
    {
        //Exercise 19.
        //Write a program that extracts from a given text all dates that match the format DD.MM.YYYY. 
        //Display them in the standard date format for Canada.

        string text = @"I was born at 14.06.1980. My sister was born at 3.7.1984. In 5/1999 I graduated my high school. 
                        The law says (see section 7.3.12) that we are allowed to do this (section 7.4.2.9).";
        string format = "dd.MM.yyyy";
        MatchCollection date = Regex.Matches(text, @"\d{2}.\d{2}.\d{4}");
        
        foreach (var item in date)
        {
            string itemString = Convert.ToString(item);
            DateTime parsedDate = DateTime.ParseExact(itemString, format, CultureInfo.InvariantCulture);
            Console.WriteLine(parsedDate.ToString(CultureInfo.GetCultureInfo("en-CA")));
        }
    }
}

